Activités (Activities)
Plus récente (Latest)
False
Activités de productivité
Last updated 1 juil. 2024

API de Google Drive

Crée un service Google Drive.

Espace de noms: UiPath.Gsuite.Activities.API

Assembly: UiPath.Gsuite.Activities.API (dans UiPath.Gsuite.Activities.API.dll)

Constructeurs

ConstructeurDescriptionSyntaxe
ServiceGoogleDriveInitialise une nouvelle instance de la classe GoogleDriveService
public class GoogleDriveService : IGoogleDriveServicepublic class GoogleDriveService : IGoogleDriveService

Méthodes

NomDescription
Apply File LabelsApplique les libellés Google Drive au fichier spécifié.
Effacer les champs de libellé du fichier (Clear File Label Fields)Supprime un ou plusieurs champs de libellé d'un fichier.
Copy FileCopie un fichier dans un emplacement Google Drive spécifié.
Créer un dossier (Create Folder)Crée un dossier à l'emplacement Google Drive spécifié.
Supprimer l'élémentSupprime un fichier ou un dossier spécifié.
Télécharger le fichierTélécharge le fichier spécifié.
Obtenir les libellés du Drive (Get Drive Labels)Obtient les libellés de lecteur avec des champs vides.
Get FileObtient un fichier à partir de Google Drive par chemin relatif ou par URL, ID ou chemin complet.
Obtenir les libellés de fichier (Get File Labels)Récupère une liste des fichiers à partir de l'emplacement Google Drive spécifié.
Get FilesRécupère une liste des fichiers à partir de l'emplacement Google Drive spécifié.
GetFilesandFoldersRécupère une liste de fichiers et de dossiers à partir de l'emplacement Google Drive spécifié.
Get Folder

Obtient un dossier à partir de Google Drive par chemin relatif, ou par URL, ID ou chemin complet.

Obtenir les dossiersRécupère une liste des dossiers à partir de l'emplacement Google Drive spécifié.
Obtenir un élément

Obtient un fichier ou un dossier à partir de Google Drive par chemin relatif ou par URL, ID ou chemin complet.

Move FileDéplace un dossier vers le dossier de destination spécifié dans Google Drive.
Move FolderDéplace un dossier vers le dossier de destination spécifié dans Google Drive.
RefreshFileObtient la dernière version du fichier spécifié.
ActualiserDossierObtient la dernière version du dossier spécifié.
RefreshItemObtient la dernière version du fichier ou dossier spécifié.
Remove File LabelsSupprime les libellés d'un fichier.
Share File

Partage un fichier avec tout le monde, avec un domaine ou avec les destinataires spécifiés.

Partager le dossier

Partage un dossier avec tout le monde, avec un domaine ou avec les destinataires spécifiés.

Upload FileCharge un fichier dans Google Drive
Upload FilesUploads files to Google Drive

Exemple

Dans l'exemple suivant, vous pouvez voir comment utiliser les API pour renommer tous les fichiers d'un dossier Google Drive en ajoutant un sous-fixe.
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class Rename_all_the_files_in_a_Google_Drive_folder : CodedWorkflow
    {
        [Workflow]
        public void Execute(string NameSubfix)
        {
           var service = google.Drive(connections.Drive.<connectionID>);
            
            var folderUrl ="https://drive.google.com/drive/folders/1sE7UqjderUPv24Rxkto5jyefAuVLeVCz";
            var folder = service.GetFolder(folderUrl,IdentificationType.UrlOrId);
            var files = service.GetFiles(folder);
            foreach (var file in files)
            {
                System.Console.WriteLine(file.FullName);
                file.Move(folder,file.FullName+"-"+NameSubfix,ConflictBehavior.Replace);
                
            }
        }
    }
}using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class Rename_all_the_files_in_a_Google_Drive_folder : CodedWorkflow
    {
        [Workflow]
        public void Execute(string NameSubfix)
        {
           var service = google.Drive(connections.Drive.<connectionID>);
            
            var folderUrl ="https://drive.google.com/drive/folders/1sE7UqjderUPv24Rxkto5jyefAuVLeVCz";
            var folder = service.GetFolder(folderUrl,IdentificationType.UrlOrId);
            var files = service.GetFiles(folder);
            foreach (var file in files)
            {
                System.Console.WriteLine(file.FullName);
                file.Move(folder,file.FullName+"-"+NameSubfix,ConflictBehavior.Replace);
                
            }
        }
    }
}
Dans l'exemple suivant, vous pouvez voir comment utiliser les API pour lire tous les fichiers d'un dossier, y compris les sous-dossiers.
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Drive.Models;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class ReadAllFilesFromAFolder : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {            
            var service = google.Drive(connections.Drive.<connectionID>);     
         
            // Read All files from Google Drive and its subfolders 
            readFilesInAFolder(null,service);
            
        }
        // Read All files from a Folder including all subfolders
        public void readFilesInAFolder(IFolder? googleFolder, IGoogleDriveService service)
        {
            var filesAndFolders = service.GetFilesAndFolders(googleFolder);
        
            foreach (var fileFolder in filesAndFolders.OrderBy(f=> f.IsFolder))
            {
                if(!fileFolder.IsFolder)
                {
                    var folder = service.GetFolder(fileFolder.Item.ParentId);
                    
                    Log("Folder: "+ folder.FullName+" FileName: "+fileFolder.FullName+ " Type: "+fileFolder.Item.MimeType);
                }
                else
                {
                    readFilesInAFolder(fileFolder as IFolder, service);
                }
            }
            
        }
    }
    
}using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Drive.Models;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class ReadAllFilesFromAFolder : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {            
            var service = google.Drive(connections.Drive.<connectionID>);     
         
            // Read All files from Google Drive and its subfolders 
            readFilesInAFolder(null,service);
            
        }
        // Read All files from a Folder including all subfolders
        public void readFilesInAFolder(IFolder? googleFolder, IGoogleDriveService service)
        {
            var filesAndFolders = service.GetFilesAndFolders(googleFolder);
        
            foreach (var fileFolder in filesAndFolders.OrderBy(f=> f.IsFolder))
            {
                if(!fileFolder.IsFolder)
                {
                    var folder = service.GetFolder(fileFolder.Item.ParentId);
                    
                    Log("Folder: "+ folder.FullName+" FileName: "+fileFolder.FullName+ " Type: "+fileFolder.Item.MimeType);
                }
                else
                {
                    readFilesInAFolder(fileFolder as IFolder, service);
                }
            }
            
        }
    }
    
}
  • Constructeurs
  • Méthodes
  • Exemple

Cette page vous a-t-elle été utile ?

Obtenez l'aide dont vous avez besoin
Formation RPA - Cours d'automatisation
Forum de la communauté UiPath
Logo Uipath blanc
Confiance et sécurité
© 2005-2024 UiPath. All rights reserved.